<template>
    <div class="order-detail-container">
        <Header :info="orderInfo" :seatInfo="seatInfo" v-if="orderInfo"></Header>
        <Other v-if="orderInfo" :info="orderInfo"></Other>
        <Footer :info="orderInfo" v-if="orderInfo"></Footer>
    </div>
</template>
<script setup lang="ts">
import Header from "./header.vue";
import Footer from "./footer.vue"
import Other from "./other.vue";
import Taro from "@tarojs/taro";
import { storeToRefs } from 'pinia';
import { onMounted, ref } from "vue";
import { useUserStore } from '../../store';
import * as orderApi from "../../api/order";
import * as loginApi from '../../api/loginApi'
const router = Taro.useRouter();
const currentOrderId: any = ref(null);
const currentOrderInfo: any = ref(null);
const buyType = ref(0);
const auto_check_seat = ref(0);
const orderInfo = ref({})
const seatInfo = ref([])
const ticketInfo = ref({})
const userStore = useUserStore()
const { Token,
    Userinfo } = storeToRefs(userStore)


onMounted(() => {
    currentOrderId.value = router.params.orderId;
    getDetails();
    getUserInfo()
});
//获取用户信息
const getUserInfo = async () => {
    const res = await loginApi.userInfo({ userId: Userinfo.value.id }).then((res) => res.data)
    userStore.setUserinfo(res)
    Taro.setStorageSync("userInfo", res);

}
//提交订单接口
const getDetails = async () => {
    const data = {
        orderNumber: currentOrderId.value,
    };
    const res: any = await orderApi.orderDetail(data);
    if (res.state == 200) {
        orderInfo.value = res.data.orderInfo
        seatInfo.value = res.data.seatInfo
        ticketInfo.value = res.data.ticketInfo
    }
};
</script>
<style lang="scss">
.order-detail-container {
    display: flex;
    flex-direction: column;
    padding: 0 25px;
}
</style>
